<template>
    <!-- pointer-events: none; -->
    <iframe  src="" id="iframe" style="width:100% ;" :style="istype == '1' ? 'height:740px' : 'height: 790px'"></iframe>
</template>
<script>
import PreviewPdf from '@/utils/previewPdf'
import { sydm, pdfIsEncryption } from "@/api/archive/fileCollection/offlinReception.js";
export default {
    props: ["url", "istype", "operate", 'source', 'item'],
    watch: {
        url: {
            handler(newVal) {
                //  console.log(newVal, this.item, this.item != undefined, "lsdjfklsdjfk")
                const href = URL.createObjectURL(new Blob([newVal], { type: 'application/pdf;charset=utf-8' }))

                if (this.item != undefined) {
                    sydm({
                        sydm: "yulan"
                    }).then(res => {
                            console.log(res,"yewu,====================================")
                        pdfIsEncryption({
                            docId: this.item.DOC_ID,
                            categoryId: this.item.categoryId
                        }).then(res1 => {
                            console.log(res1, "----------------------")
                            if (res1.data) {
                                new PreviewPdf({
                                    blob: newVal,
                                    docTitle: 'window.open docTitle',
                                    isAddWatermark: false,
                                    watermark: {
                                        type: 'canvas',
                                        text: res.data.synr
                                    }
                                });
                            } else {
                                new PreviewPdf({
                                    blob: newVal,
                                    docTitle: 'window.open docTitle',
                                    isAddWatermark: true,
                                    watermark: {
                                        type: 'canvas',
                                        text: res.data.synr
                                    }
                                });
                            }

                        })



                    })
                } else {

                    //不加水印
                    new PreviewPdf({
                        blob: newVal,
                        docTitle: 'window.open docTitle',
                        isAddWatermark: false,
                        watermark: {
                            type: 'canvas',
                            text: "222"
                        }
                    });
                }









            },
            immediate: true
        }
    },
    data() {
        return {

        }
    },
    created() {

    }
}
</script>
<style scoped>
.viewer-container {
    z-index: 9999999999;
}
</style>
